/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : FindWordMeaningHandler.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Dec 26, 2008       Raghu Sarraff			       Created
 */
package lwf.handler.english.word;

import java.util.List;

import net.lwf.entity.AttemptedQuestion;
import net.lwf.entity.QuestionInfo;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;

import lwf.handler.IProcessHandler;
import lwf.handler.ProcessHandler;
import lwf.handler.helper.DisplayFormatter;
import lwf.handler.helper.FormatAttribute;

/**
 * Type the class description here
 *  
 */
public class FindWordMeaningHandler extends ProcessHandler implements IProcessHandler {

	private String word;
	private FormatAttribute format;
	
	public FindWordMeaningHandler(String word) {
		this.word = word;
	}
	
	/**
	 * @see net.lwf.handler.IProcessHandler#getDisplayFormatter()
	 */
	public DisplayFormatter getDisplayFormatter() {
		format = new FormatAttribute();
		
		format.setQuestionNumber(getQuestionNum());
		format.setQuestionTable(this.generateQuestionTable());
		format.setQuestionType(1); 
		
		return new DisplayFormatter(format);
	}
	
	/**
	 * @see net.lwf.handler.IProcessHandler#getQuestionDesc()
	 */
	public String getQuestionDesc() {
		return "What is the meaning for the word, <b>" + this.word + "</b>?";
	}
	
	private String generateQuestionTable() {
		StringBuffer sbQBlock = new StringBuffer();
		sbQBlock.append("<table width=\"100%\" border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\">");
			sbQBlock.append("<tr>");
				sbQBlock.append("<td class=\"questionmedium\">");
					sbQBlock.append("What is the meaning for the word below?");		
				sbQBlock.append("</td>");
			sbQBlock.append("</tr>");
			sbQBlock.append("<tr>");
				sbQBlock.append("<td>&nbsp;</td>");
		    sbQBlock.append("</tr>");
			sbQBlock.append("<tr>");
				sbQBlock.append("<td class=\"dataleft\">" + this.word + "</td>");
			sbQBlock.append("</tr>");
			sbQBlock.append("<tr>");
				sbQBlock.append("<td><hr></td>");
			sbQBlock.append("</tr>");
		sbQBlock.append("</table>");
		
		return sbQBlock.toString();
	}

	//------------------------------------------------ Methods for PDF generation on the browser
	public void generate(Document document) {
	
	}

	@Override
	public List<QuestionInfo> generateMultiple() {
		return null;
	}

	@Override
	public QuestionInfo generateSingle() {
		return null;
	}

	@Override
	public int getColumns() {
		return 0;
	}

	@Override
	public void getContent(Document document) throws DocumentException {
	}

	@Override
	public int getRows() {
		return 0;
	}

	@Override
	public boolean isPortrait() {
		return false;
	}

	@Override
	public String getPdfInstructionalText() {
		return null;
	}

	public boolean matchAnswer(String useranswer, AttemptedQuestion aq) {
		return false;
	}

	@Override
	public String getPdfNote() {
		return null;
	}
	
	
}

